<?php if ( ! defined('BASEPATH')) exit('This file does not run directly. Sorry.'); ?>
<?php
/**
 * Kalaisoo.
 *
 * A lightweight no-framework framework written in PHP.
 *
 * @package Kalaisoo
 * @author $Author: info@sah-company.com $
 */
?>

<!-- Tools for a document -->
<?php
/**
 * if there is a menu, display a unordered list as a menu for the bean.
 */
if (isset($toolbar['actions']) && count($toolbar['actions'])):
?>
<nav class="action <?php echo $toolbar['current']; ?>">
	<h2><?php echo __('actions'); ?></h2>
	<ul>
<?php
	foreach ($toolbar['actions'] as $action=>$allowed):
		$actionUrl = sprintf($toolbar['url'], $action);
		$class = 'action '.$action;
		if ( ! $allowed) $class .= ' forbidden';
?>
		<li>
			<a
				href="<?php echo $actionUrl; ?>"
				class="<?php echo $class; ?>">
				<?php echo __($action.'_action'),"\n"; ?>
			</a>
		</li>
<?php
	endforeach;
?>
	</ul>
<?php
if (isset($urlPrevPage) || isset($urlNextPage)):
?>
	<ul class="left">
		<li>
			<a 
				href="<?php echo $urlPrevPage; ?>"
				class="action prev">
				<?php echo __('prev_action'),"\n"; ?>
			</a>
		</li>
		<li>
			<a 
				href="<?php echo $urlNextPage; ?>"
				class="action next">
				<?php echo __('next_action'),"\n"; ?>
			</a>
		</li>
	</ul>
<?php
endif;
?>
<?php
/**
 * display model special stuff on the right
 */
if (isset($model['actions']) && count($model['actions'])):
?>
	<form id="model-action" class="right" method="get" accept-charset="utf-8">
		<div>
			<select id="action" name="action" onchange="location.href=this.value; return false;">
				<option value=""><?php echo __('select_action'); ?></option>
<?php
	foreach ($model['actions'] as $action=>$allowed):
		$actionUrl = sprintf($toolbar['url'], $action);
?>
				<option value="<?php echo $actionUrl; ?>"><?php echo __($action.'_action'); ?></option>
<?php
	endforeach;
?>
			</select>
		</div>
	</form>
<?php
endif;
?>
<?php
/**
 * display model special filters on the left, if any
 */
if (isset($model['filters']) && count($model['filters'])):
?>
	<form id="model-filter" class="left" method="get" accept-charset="utf-8">
		<div>
			<select id="filter" name="filter" onchange="location.href=this.value; return false;">
<?php
	foreach ($model['filters'] as $filter=>$params):
		$actionUrl = sprintf($urlPatternFilter, $filter);
		$selected = null;
		if ($model['filter'] == $filter) $selected = ' selected="selected"';
?>
				<option value="<?php echo $actionUrl; ?>"<?php echo $selected; ?>><?php echo $params['label']; ?></option>
<?php
	endforeach;
?>
			</select>
		</div>
	</form>
<?php
endif;
?>
</nav>
<?php
endif;
?>
<!-- /Tools -->